#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;
int main() {
    int n, x;
    cin >> n >> x;

    vector<ll> arr(n+1);

    for (int i = 1; i <= n; i++)
        cin >> arr[i];
    sort(arr.begin()+1, arr.end());

    ll ret = 0;
    int pos=max(0,n-x);
    ret=arr[pos]*x;
    for(int i=pos+1;i<=n;i++)
    {
        ret+=arr[i]-arr[pos];
    }
    cout << ret << endl;
    return 0;
}
//2 3 4 5 6
//0 1 2 3 4 
